<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>主页</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" href="stylesheets/screen.css"/>
    <link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .userinfo {
            margin-left: 60%;
        }
    </style>
    <script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="js/common.js" type="text/javascript"></script>
    <script src="js/gk.js" type="text/javascript"></script>
    <script>
        function initPage() {
            if (sessionGet(getKey()) != null) {
                $("#curuser").html("当前用户：<a href='./userinfo.html'>" + sessionGet(getKey()) + "</a>")
            }
            $("#downloadA").live("click", downLoadFile);
            $("#upLoadBtn").live("click", upLoadFile);
            //下载文件
            function downLoadFile() {
                $.ajax({
                    url: c.BASE_URL_DEV + "loginController/checkDownRole",
                    type: "POST",
                    data: {fid: 100, uid: sessionGet("uid"), token: getKey()},
                    dataType: "jsonp",
                    jsonp: "callback",
                    success: function (data) {
                        console.log(data);
                        var _r = data.result;
                        if (_r.code != 200) {
                            alert(_r.msg);
                            sessionStorage.clear();
                            location.href = "login.html";
                        } else {
                            window.open(c.BASE_URL_DEV + "loginController/" + _r.obj);
                        }
                    },
                    error: function (er) {
                        console.log(er);
                    }
                });
            }
            //上传文件
            function upLoadFile() {
                //获取文件
                var _fE = document.getElementById("userfile");
                var oMyForm = new FormData();
                oMyForm.append("username", "Groucho");
                oMyForm.append("accountnum", 123456);
                oMyForm.append("userfile", _fE.files[0]);
                var oReq = new XMLHttpRequest();
                oReq.open("POST", "http://foo.com/submitform.php");
                oReq.send(oMyForm);
            }
        }
        $(initPage);
    </script>

</head>
<body>
<!--<div class="widthtest">
    <span>这是个一个提示层</span>
</div>-->
<div class="container">
    <div class="page-header">
        <h2>主页</h2>

        <div id="curuser" class="userinfo"><a href="./login.html">请登录</a></div>
    </div>
    <div class="clearfix"></div>
    <div class="row">
        <div class="col-xl-6">
            <a href="javascript:void(0);" id="downloadA">附件下载</a>

           <!-- <form>
                <div class="form-group">
                    <label for="userfile"></label>
                    <input type="file" id="userfile">
                </div>
                <button type="submit" id="upLoadBtn" class="btn btn-default">上传</button>
            </form>-->
        </div>
        <div class="col-xl-6" id=""></div>
    </div>
</div>


</body>
</html>